package com.jxnu.duewang.zmly.fragment;


import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jxnu.duewang.zmly.R;
import com.jxnu.duewang.zmly.zhangHaoQi.Allanchor;
import com.jxnu.duewang.zmly.zhangHaoQi.AnchorNew;
import com.jxnu.duewang.zmly.zhangHaoQi.Anchor_recycleriewadapter;
import com.jxnu.duewang.zmly.zhangHaoQi.Httpsever;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;


/**
 * A simple {@link Fragment} subclass.
 */
public class AnchorFragment extends BaseFragment implements Callback<Allanchor> {


    private RecyclerView recyclerView;
    private int page=1;
    private boolean isBottom=false;

    public AnchorFragment() {
        // Required empty public constructor
    }

    @Override
    public String getFragmnetTitle() {
        return "主播";
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_anchor, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        recyclerView = (RecyclerView) view.findViewById(R.id.anchor_recyclerview);
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://mobile.ximalaya.com")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        Httpsever httpsever=retrofit.create(Httpsever.class);
        httpsever.getanchore("android",1).enqueue(this);
    }

    @Override
    public void onResponse(Call<Allanchor> call, Response<Allanchor> response) {
        List<AnchorNew> list=response.body().getList();
        Anchor_recycleriewadapter anchoradapter=new Anchor_recycleriewadapter(list,getContext());
        recyclerView.setAdapter(anchoradapter);
    }

    @Override
    public void onFailure(Call<Allanchor> call, Throwable t) {

    }
}
